package com.ruoyi.ylyx.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ylyx.domain.YlyxAccounthistory;
import com.ruoyi.ylyx.service.IYlyxAccounthistoryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 游戏账户变动Controller
 * 
 * @author yuexl
 * @date 2021-02-05
 */
@Controller
@RequestMapping("/ylyx/accounthistory")
public class YlyxAccounthistoryController extends BaseController
{
    private String prefix = "ylyx/accounthistory";

    @Autowired
    private IYlyxAccounthistoryService ylyxAccounthistoryService;

    @RequiresPermissions("ylyx:accounthistory:view")
    @GetMapping()
    public String accounthistory()
    {
        return prefix + "/accounthistory";
    }

    /**
     * 查询游戏账户变动列表
     */
    @RequiresPermissions("ylyx:accounthistory:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YlyxAccounthistory ylyxAccounthistory)
    {
        startPage();
        List<YlyxAccounthistory> list = ylyxAccounthistoryService.selectYlyxAccounthistoryList(ylyxAccounthistory);
        return getDataTable(list);
    }

    /**
     * 导出游戏账户变动列表
     */
    @RequiresPermissions("ylyx:accounthistory:export")
    @Log(title = "游戏账户变动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YlyxAccounthistory ylyxAccounthistory)
    {
        List<YlyxAccounthistory> list = ylyxAccounthistoryService.selectYlyxAccounthistoryList(ylyxAccounthistory);
        ExcelUtil<YlyxAccounthistory> util = new ExcelUtil<YlyxAccounthistory>(YlyxAccounthistory.class);
        return util.exportExcel(list, "accounthistory");
    }

    /**
     * 新增游戏账户变动
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存游戏账户变动
     */
    @RequiresPermissions("ylyx:accounthistory:add")
    @Log(title = "游戏账户变动", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YlyxAccounthistory ylyxAccounthistory)
    {
        return toAjax(ylyxAccounthistoryService.insertYlyxAccounthistory(ylyxAccounthistory));
    }

    /**
     * 修改游戏账户变动
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        YlyxAccounthistory ylyxAccounthistory = ylyxAccounthistoryService.selectYlyxAccounthistoryById(id);
        mmap.put("ylyxAccounthistory", ylyxAccounthistory);
        return prefix + "/edit";
    }

    /**
     * 修改保存游戏账户变动
     */
    @RequiresPermissions("ylyx:accounthistory:edit")
    @Log(title = "游戏账户变动", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YlyxAccounthistory ylyxAccounthistory)
    {
        return toAjax(ylyxAccounthistoryService.updateYlyxAccounthistory(ylyxAccounthistory));
    }

    /**
     * 删除游戏账户变动
     */
    @RequiresPermissions("ylyx:accounthistory:remove")
    @Log(title = "游戏账户变动", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ylyxAccounthistoryService.deleteYlyxAccounthistoryByIds(ids));
    }
}
